package factory.one.command;

import com.alibaba.fastjson2.JSON;
import factory.one.entity.Product;
import factory.one.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author sk.z
 * 2023/7/6
 * 客户
 **/
@Service
public class CmdProduct {

    @Autowired
    private ProductService productService;

    public void add(String name) {
        Product newOne = new Product();
        newOne.setName(name);
        newOne.setStatus(1);
        productService.add(newOne);
    }

    public void list() {
        productService.listAll().forEach(e -> System.out.println(JSON.toJSONString(e)));
    }

}
